package sliver.action.shop;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import sliver.entity.Shopper;
import sliver.entity.Vip;
import sliver.service.shop.vip.VipLevelService;

import com.opensymphony.xwork2.ActionSupport;

@Scope("prototype")
@Controller("shop.ajax.toListShopVipLevelAction")
public class ToListShopVipLevelAction extends ActionSupport implements RequestAware, SessionAware{

	private static final long serialVersionUID = 7297491358978185035L;
	
	private Map<String, Object> request;
	private Map<String, Object> session;
	
	@Autowired
	private VipLevelService vipLevelService;
	
	public ToListShopVipLevelAction(){
		
	}
	
	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	@Override
	public void setRequest(Map<String, Object> request) {
		this.request = request;
	}
	
	@Override
	public String execute() throws Exception {
		
		Shopper shopper = Shopper.class.cast(session.get("login_shopper"));
		
		List<Vip> vips = vipLevelService.listVipLevels(shopper.getId());
		request.put("vips", vips);
		
		return SUCCESS;
	}
}
